{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8366e979-feb5-4280-b183-1b05e7cd73b5",
   "metadata": {
    "jp-MarkdownHeadingCollapsed": true
   },
   "source": [
    "- 创建 `list`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3cb0f5aa-114f-4e12-bd4f-686f2b9ab6de",
   "metadata": {},
   "outputs": [],
   "source": [
    "numbers = list(range(10))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "58a0ef6d-1b03-4f2f-8c3f-94ab8b71deb3",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "numbers"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "90be7d62-d47e-4c6c-b49a-529623d5a323",
   "metadata": {},
   "source": [
    "- 使用 `map`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "17bdd693-4396-479a-aba8-3c32b41c967d",
   "metadata": {},
   "outputs": [],
   "source": [
    "num_map = list(map(lambda x: x * x, numbers))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4871093e-265f-45cd-917c-bcef4cc0b1e6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "num_map"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "128f270d-7641-4416-b564-18f7f46136cf",
   "metadata": {},
   "source": [
    "- 使用 列表推导式 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "bd5b2376-df8b-4943-88a1-3d75369fb5e5",
   "metadata": {},
   "outputs": [],
   "source": [
    "num_derive = [x * x for x in numbers]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "aa197cb6-46f4-4e00-903d-7863fa9efe60",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "num_derive"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0a3f1263-4aa2-4c16-b575-b4bca858a5b0",
   "metadata": {},
   "source": [
    "- 使用 `filter`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "47a6e22b-f028-4e6d-991a-018d2882be59",
   "metadata": {},
   "outputs": [],
   "source": [
    "num_filter = list(filter(lambda x: x % 2 == 0, numbers))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "785541fb-3e4f-48f9-a220-4c5258abe4c4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 2, 4, 6, 8]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "num_filter"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fc7eda67-fb84-4e37-a1ab-e097b67048a9",
   "metadata": {},
   "source": [
    "- 使用 列表推导式 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "c810ee86-1f4c-47a0-8fb2-24296f49fb68",
   "metadata": {},
   "outputs": [],
   "source": [
    "jnum_derive = [x for x in numbers if x % 2 == 0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "ce8a9ef8-df22-49c9-b398-810aaa439929",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "num_derive"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Py(Python note)",
   "language": "python",
   "name": "pynote"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
